<template>
	<view class="container">
		<view>
			<desc-wrapper :title="title" :desc="desc"></desc-wrapper>
			<z-card justifyContent="center">
				<view class="card-content-item">
					<view class="w-full h-full flex-1">
						<view class="input-name-box">
							<input class="input-item" v-model="form.name" type="text" placeholder="输入您的名字(只包含中文)" />
						</view>
					</view>
				</view>
			</z-card>
			<view class="bottom-btns">
				<view class="start-btn" @click="onClick_1">
					<text class="">立即打分</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '姓名打分',
				desc: '测试方法：输入您的名字，点击立即打分，并查看结果，请自行体会其中的指示',
				form: {
					name: '',
				},
			};
		},
		methods: {
			onClick_1() {
				let that = this;
				if (this.form.name == "" || (!/^(?:[\u4e00-\u9fa5·]{2,16})$/.test(this.form.name))) {
					uni.$u.toast("请输入您的中文姓名")
					return
				}
				uni.request({
					url: 'https://cs.appzdm.com:3000/Dafen/xingming',
					method: 'POST',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: this.form,
					success: (res) => {
						console.log(res.data.data, '###########');
						uni.navigateTo({
							url: `/pages/nameanalysis/detail?params=${JSON.stringify(res.data.data)}&keyname=${this.form.title_zhougong}`
						})
					},
					fail: (error) => {
						console.error('Request Failed:', error);
					}
				});

			},
		},
	};
</script>
<style lang="scss">
</style>